Advertisement
Guest User

Untitled

a guest
Jul 5th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.25 KB | None | 0 0
  1.  
  2. <?php
  3. $data_operation = $this->pdo('select * from operations, users_operations where operations.id = users_operations.id_operation &&  = ?', [
  4.     $this->id
  5. ])->fetchAll(PDO::FETCH_OBJ);
  6.  
  7. $data_mission = $this->pdo('select * from missions, users_operations where missions.id = users_missions.id_mission && users_missions.id_user = ?', [
  8.     $this->id
  9. ])->fetchAll(PDO::FETCH_OBJ);
  10.  
  11. $this->set(compact('data_operation', 'data_mission'));
  12.  
  13.  
  14.  
  15. <?php foreach ($data_operation as $key => $operation) : ?>
  16.     <!--вывод операций-->
  17.     <?php
  18.     $mission_array = [];
  19.     foreach ($data_mission as $v) {
  20.     if ($v->id_operation == $operation->id){
  21. ?>
  22.   <!--вывод миссий операций-->
  23. <?
  24.     }
  25.        
  26.     }
  27.     ?>
  28.  
  29. <?php endforeach; ?>
  30. ---------
  31. <?php
  32. $data = $this->pdo('select {только то что юзаешь и если дублируется делаешь алиасы} from missions m left join users_operations uo on u.id=uo.id_mission left join operations o on o.id=uo.id_operation where uo.id_user=?', [
  33.     $this->id
  34. ])->fetchAll(PDO::FETCH_OBJ);
  35. $lastOpID=0;
  36. foreach($data as $item){
  37. if($item->operation_id!=$lastOpId){
  38. //operations
  39. $lastOpId=$item->operation_id;
  40. }else{
  41. //missions
  42.  
  43. }
  44.  
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement